<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>libwebsockets: Protocols and Plugins</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="libwebsockets.org-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libwebsockets
   </div>
   <div id="projectbrief">Lightweight C library for HTML5 websockets</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__Protocols-and-Plugins.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#groups">Modules</a> &#124;
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Protocols and Plugins</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="groups"></a>
Modules</h2></td></tr>
<tr class="memitem:group__generic-sessions"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__generic-sessions.html">plugin: generic-sessions</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlws__protocols.html">lws_protocols</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlws__plugin__capability.html">lws_plugin_capability</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structlws__plugin.html">lws_plugin</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ga40994491e1567f91f579d2b444775266"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga40994491e1567f91f579d2b444775266"></a>
typedef int(*&#160;</td><td class="memItemRight" valign="bottom"><b>lws_plugin_init_func</b>) (struct lws_context *, struct <a class="el" href="structlws__plugin__capability.html">lws_plugin_capability</a> *)</td></tr>
<tr class="separator:ga40994491e1567f91f579d2b444775266"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga83f7a924ba790fa273476075a59f08b0"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga83f7a924ba790fa273476075a59f08b0"></a>
typedef int(*&#160;</td><td class="memItemRight" valign="bottom"><b>lws_plugin_destroy_func</b>) (struct lws_context *)</td></tr>
<tr class="separator:ga83f7a924ba790fa273476075a59f08b0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga25754726d97c5f519d313e691a9fe29d"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#ga25754726d97c5f519d313e691a9fe29d">lws_vhost_name_to_protocol</a> (struct lws_vhost *vh, const char *name)</td></tr>
<tr class="separator:ga25754726d97c5f519d313e691a9fe29d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga72ad550786ca7976463589d347e62112"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#ga72ad550786ca7976463589d347e62112">lws_get_protocol</a> (struct lws *wsi)</td></tr>
<tr class="separator:ga72ad550786ca7976463589d347e62112"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8bbe5e65faca068845704bab911a5030"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#ga8bbe5e65faca068845704bab911a5030">lws_protocol_get</a> (struct lws *wsi) LWS_WARN_DEPRECATED</td></tr>
<tr class="separator:ga8bbe5e65faca068845704bab911a5030"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaec0c0477288ff3f83aff38d357b883d1"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#gaec0c0477288ff3f83aff38d357b883d1">lws_protocol_vh_priv_zalloc</a> (struct lws_vhost *vhost, const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *prot, int size)</td></tr>
<tr class="separator:gaec0c0477288ff3f83aff38d357b883d1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf3be4243443baac0f8be1fcfb4d25129"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#gaf3be4243443baac0f8be1fcfb4d25129">lws_protocol_vh_priv_get</a> (struct lws_vhost *vhost, const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *prot)</td></tr>
<tr class="separator:gaf3be4243443baac0f8be1fcfb4d25129"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga106b37ae9c247e84d191ab09441adc43"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__Protocols-and-Plugins.html#ga106b37ae9c247e84d191ab09441adc43">lws_finalize_startup</a> (struct lws_context *context)</td></tr>
<tr class="separator:ga106b37ae9c247e84d191ab09441adc43"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<h2>Protocol and protocol plugin -related apis</h2>
<p>Protocols bind ws protocol names to a custom callback specific to that protocol implementaion.</p>
<p>A list of protocols can be passed in at context creation time, but it is also legal to leave that NULL and add the protocols and their callback code using plugins.</p>
<p>Plugins are much preferable compared to cut and pasting code into an application each time, since they can be used standalone. </p>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga106b37ae9c247e84d191ab09441adc43"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN int lws_finalize_startup </td>
          <td>(</td>
          <td class="paramtype">struct lws_context *&#160;</td>
          <td class="paramname"><em>context</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__Protocols-and-Plugins.html#ga106b37ae9c247e84d191ab09441adc43">lws_finalize_startup()</a> - drop initial process privileges</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">context</td><td>lws context</td></tr>
  </table>
  </dd>
</dl>
<p>This is called after the end of the vhost protocol initializations, but you may choose to call it earlier </p>

</div>
</div>
<a class="anchor" id="ga72ad550786ca7976463589d347e62112"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a>* lws_get_protocol </td>
          <td>(</td>
          <td class="paramtype">struct lws *&#160;</td>
          <td class="paramname"><em>wsi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__Protocols-and-Plugins.html#ga72ad550786ca7976463589d347e62112">lws_get_protocol()</a> - Returns a protocol pointer from a websocket connection. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">wsi</td><td>pointer to struct websocket you want to know the protocol of</td></tr>
  </table>
  </dd>
</dl>
<pre class="fragment"> Some apis can act on all live connections of a given protocol,
 this is how you can get a pointer to the active protocol if needed.</pre> 
</div>
</div>
<a class="anchor" id="ga8bbe5e65faca068845704bab911a5030"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a>* lws_protocol_get </td>
          <td>(</td>
          <td class="paramtype">struct lws *&#160;</td>
          <td class="paramname"><em>wsi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__Protocols-and-Plugins.html#ga8bbe5e65faca068845704bab911a5030">lws_protocol_get()</a> - deprecated: use lws_get_protocol </p>

</div>
</div>
<a class="anchor" id="gaf3be4243443baac0f8be1fcfb4d25129"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN void* lws_protocol_vh_priv_get </td>
          <td>(</td>
          <td class="paramtype">struct lws_vhost *&#160;</td>
          <td class="paramname"><em>vhost</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *&#160;</td>
          <td class="paramname"><em>prot</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__Protocols-and-Plugins.html#gaf3be4243443baac0f8be1fcfb4d25129">lws_protocol_vh_priv_get()</a> - retreive a protocol's per-vhost storage</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">vhost</td><td>vhost the instance is related to </td></tr>
    <tr><td class="paramname">prot</td><td>protocol the instance is related to</td></tr>
  </table>
  </dd>
</dl>
<p>Recover a pointer to the allocated per-vhost storage for the protocol created by <a class="el" href="group__Protocols-and-Plugins.html#gaec0c0477288ff3f83aff38d357b883d1">lws_protocol_vh_priv_zalloc()</a> earlier </p>

</div>
</div>
<a class="anchor" id="gaec0c0477288ff3f83aff38d357b883d1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN void* lws_protocol_vh_priv_zalloc </td>
          <td>(</td>
          <td class="paramtype">struct lws_vhost *&#160;</td>
          <td class="paramname"><em>vhost</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const struct <a class="el" href="structlws__protocols.html">lws_protocols</a> *&#160;</td>
          <td class="paramname"><em>prot</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__Protocols-and-Plugins.html#gaec0c0477288ff3f83aff38d357b883d1">lws_protocol_vh_priv_zalloc()</a> - Allocate and zero down a protocol's per-vhost storage </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">vhost</td><td>vhost the instance is related to </td></tr>
    <tr><td class="paramname">prot</td><td>protocol the instance is related to </td></tr>
    <tr><td class="paramname">size</td><td>bytes to allocate</td></tr>
  </table>
  </dd>
</dl>
<p>Protocols often find it useful to allocate a per-vhost struct, this is a helper to be called in the per-vhost init LWS_CALLBACK_PROTOCOL_INIT </p>

</div>
</div>
<a class="anchor" id="ga25754726d97c5f519d313e691a9fe29d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">LWS_VISIBLE LWS_EXTERN const struct <a class="el" href="structlws__protocols.html">lws_protocols</a>* lws_vhost_name_to_protocol </td>
          <td>(</td>
          <td class="paramtype">struct lws_vhost *&#160;</td>
          <td class="paramname"><em>vh</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
<p><a class="el" href="group__Protocols-and-Plugins.html#ga25754726d97c5f519d313e691a9fe29d">lws_vhost_name_to_protocol()</a> - get vhost's protocol object from its name</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">vh</td><td>vhost to search </td></tr>
    <tr><td class="paramname">name</td><td>protocol name</td></tr>
  </table>
  </dd>
</dl>
<p>Returns NULL or a pointer to the vhost's protocol of the requested name </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
